<?php
/**
 * Created by PhpStorm.
 * UsersF: Mloong
 * Date: 2018/12/13
 * Time: 10:47
 */

namespace app\admin\model;


use Driver\Cache\Redis;

class Product extends BaseModel
{
    /**
     * 根据id查找一条数据
     */
    public static function findOne($category_id)
    {
        return self::where('product_id','=',$category_id)
            ->find();
    }

    /**
     * 删除一条商品记录
     * 同步删除redis-hash商品详情记录
     * @param $id
     * @return bool
     */
    public static function delOne($id)
    {
        Redis::redisAccountSet('ProductID_'.$id,'del',$id);
        return self::where('product_id','=',$id)
            ->delete();
    }
}